﻿namespace DomainServices.Tools
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;

    internal class UIHintCustomAttributeBuilder : StandardCustomAttributeBuilder
    {
        public override AttributeDeclaration GetAttributeDeclaration(Attribute attribute)
        {
            UIHintAttribute attribute2 = (UIHintAttribute) attribute;
            IDictionary<string, object> controlParameters = attribute2.ControlParameters;
            if ((controlParameters == null) || (controlParameters.Count == 0))
            {
                return base.GetAttributeDeclaration(attribute);
            }
            AttributeDeclaration declaration = new AttributeDeclaration(typeof(UIHintAttribute));
            declaration.ConstructorArguments.Add(attribute2.UIHint);
            declaration.ConstructorArguments.Add(attribute2.PresentationLayer);
            foreach (KeyValuePair<string, object> pair in controlParameters)
            {
                declaration.ConstructorArguments.Add(pair.Key);
                declaration.ConstructorArguments.Add(pair.Value);
            }
            return declaration;
        }
    }
}

